<?php
/**
 * Created by PhpStorm.
 * User: vbolshov
 * Date: 03.09.2010
 * Time: 18:20:32
 */

namespace km\log;

use \SplObjectStorage;

class CompositeLogger extends Logger {
	/**
	 * @var SplObjectStorage
	 */
	private $loggers;

	function __construct(Logger $logger)
	{
		$this->loggers = new SplObjectStorage();
		$this->addLogger($logger);
	}

	function addLogger(Logger $logger)
	{
		$this->loggers->attach($logger);
	}

	function write($message)
	{
		foreach ($this->loggers as $logger) {
			$logger->write($message);
		}
	}

	protected function doFinalize()
	{
		foreach ($this->loggers as $logger) {
			$logger->finalize();
		}
	}
}
